; Music of Miami Dice (1986) (Bug Byte)
; Ripped by Megachur the 15/12/2008

	write "MIAMIDIC.BIN"

music_date_rip	equ &0fc8
music_adr	equ &a300
first_theme	equ 0	; 0 -> 0
last_theme	equ 0

	read "music_header_v1_0.asm"

;
.stop_music
;
	xor a
	ld (la7c1),a
	jp la42c
;
.init_music
;
	xor a
	ld (la7c1),a
	ld c,a
	add a
	add c
	add a
	ld c,a
	ld b,#00
	ld hl,la7c3
	add hl,bc
	ld ix,la352
	ld c,#1f
	ld a,#03
.la31e
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	push hl
	ld (ix+#10),#01
	ld (ix+#00),b
	ld (ix+#1d),b
	ld (ix+#03),e
	ld (ix+#04),d
	ex de,hl
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld (ix+#05),#02
	ld (ix+#06),b
	pop hl
	ld (ix+#01),e
	ld (ix+#02),d
	add ix,bc
	dec a
	jr nz,la31e
	inc a
	ld (la454),a
	ld (la7c1),a
	ret
.la352
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#09
.la371
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#12
.la390
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#24
;
.play_music
;
	ld a,(la7c1)
	and a
	ret z
.la3b5 equ $ + 1
	ld a,#00
	ld (la402),a
	ld hl,la454
	dec (hl)
	jr nz,la3da
	ld b,(hl)
	ld ix,la352
	call la51a
	ld ix,la371
	call la51a
	ld ix,la390
	call la51a
.la3d5
	ld hl,la454
.la3d9 equ $ + 1
	ld (hl),#01
.la3da
	ld ix,la352
	call la5bc
	ld (la6cd),hl
	ld (la6d5),a
	ld ix,la371
	call la5bc
	ld (la6cf),hl
	ld (la6d6),a
	ld ix,la390
	call la5bc
	ld (la6d1),hl
	ld (la6d7),a
.la402 equ $ + 1
	ld a,#00
	ld (la6d3),a
	ld hl,la6da
	ld d,#0d
.la40b
	ld e,(hl)
	ld b,#f4
	out (c),d
	ld bc,#f600
	out (c),c
	ld a,#c0
	out (c),a
	out (c),c
	ld b,#f4
	out (c),e
	ld b,#f6
	add a
	out (c),a
	out (c),c
	dec hl
	dec d
	jp p,la40b
	ret
.la42c
	ld de,#d000
.la42f
	call la439
	dec e
	jp p,la42f
	ld de,#073f
.la439
	ld b,#f4
	out (c),d
	ld bc,#f600
	out (c),c
	ld a,#c0
	out (c),a
	out (c),c
	ld b,#f4
	out (c),e
	ld b,#f6
	add a
	out (c),a
	out (c),c
	ret
.la454
	db #00,#bc,#a4,#a8,#ad,#6b,#9a,#95
	db #10,#84,#7c,#4a,#39,#58,#a9,#01
	xor a
	ld (la7c1),a
	pop hl
	jp la42c
	ld c,(ix+#05)
	ld b,(ix+#06)
	ld l,(ix+#03)
	ld h,(ix+#04)
	add hl,bc
	inc bc
	inc bc
	ld a,(hl)
	inc hl
	ld d,(hl)
	ld e,a
	or d
	jr nz,la48e
	ld l,(ix+#03)
	ld h,(ix+#04)
	ld bc,#0002
	ld e,(hl)
	inc hl
	ld d,(hl)
.la48e
	ld (ix+#05),c
	ld (ix+#06),b
	ld b,#00
	jp la528
	ld a,(ix+#1e)
	ld c,a
	and #07
	ld hl,la6b2
	xor (hl)
	and c
	xor (hl)
	ld (hl),a
	jp la528
	ld a,(ix+#1e)
	ld c,a
	and #38
	ld hl,la6b2
	xor (hl)
	and c
	xor (hl)
	ld (hl),a
	jp la528
	ld hl,la6b2
	ld a,(ix+#1e)
	cpl
	and (hl)
	ld (hl),a
	jr la528
	ld a,(de)
	inc de
	ld (ix+#07),b
	ld (ix+#08),b
	ld (ix+#0d),a
	set 2,(ix+#00)
	ld a,(de)
	ld (ix+#0e),a
	inc de
	jr la528
	ld a,(de)
	inc de
	ld (la3b5),a
	jr la528
	ld a,(de)
	ld (ix+#1b),a
	inc de
	ld a,(de)
	ld (ix+#1a),a
	inc de
	ld (ix+#1c),a
	jr la528
	set 7,(ix+#00)
	set 3,(ix+#00)
	jr la528
	ld (ix+#1d),b
	jr la528
	ld (ix+#1d),#40
	jr la528
	ld (ix+#1d),#c0
	jr la528
	set 1,(ix+#00)
	jr la528
	ld (ix+#13),b
	res 5,(ix+#00)
	jr la54b
.la51a
	dec (ix+#10)
	jr nz,la558
	ld (ix+#00),b
	ld e,(ix+#01)
	ld d,(ix+#02)
.la528
	ld a,(de)
	inc de
	and a
	jp m,la569
	ld (ix+#12),a
	ld a,(ix+#19)
	ld (ix+#13),a
	set 5,(ix+#00)
	set 6,(ix+#00)
	ld a,(ix+#14)
	ld (ix+#16),a
	ld a,(ix+#17)
	ld (ix+#18),a
.la54b
	ld a,(ix+#11)
	ld (ix+#10),a
	ld (ix+#02),d
	ld (ix+#01),e
	ret
.la558
	ld a,(ix+#00)
	bit 3,a
	ret z
	rla
	jr nc,la565
	inc (ix+#12)
	ret
.la565
	dec (ix+#12)
	ret
.la569
	cp #b8
	jr c,la5b4
	add #20
	jr c,la599
	add #10
	jr c,la59f
	add #10
	jr nc,la592
	ld c,a
	ld hl,la783
	add hl,bc
	ld c,(hl)
	add hl,bc
	ld (ix+#0b),l
	ld (ix+#09),l
	ld (ix+#0c),h
	ld (ix+#0a),h
	set 4,(ix+#00)
	jr la528
.la592
	add #09
	ld (la3d9),a
	jr la528
.la599
	inc a
	ld (ix+#11),a
	jr la528
.la59f
	ld (ix+#19),a
	ld a,(de)
	inc de
	ld (ix+#14),a
	ld a,(de)
	inc de
	ld (ix+#15),a
	ld a,(de)
	inc de
	ld (ix+#17),a
	jp la528
.la5b4
	ld hl,la3d5
	ld c,a
	add hl,bc
	ld c,(hl)
	add hl,bc
	jp (hl)
.la5bc
	ld c,(ix+#00)
	bit 5,c
	jr z,la607
	ld a,(ix+#16)
	sub #10
	jr nc,la5ef
	bit 6,c
	jr z,la5f4
	add (ix+#13)
	jr nc,la5d4
	sbc a
.la5d4
	add #10
	ld (ix+#13),a
	ld a,(ix+#18)
	sub #10
	jr nc,la5ea
	res 6,c
	ld a,(ix+#15)
	ld (ix+#16),a
	jr la607
.la5ea
	ld (ix+#18),a
	jr la607
.la5ef
	ld (ix+#16),a
	jr la607
.la5f4
	cpl
	sub #0f
	add (ix+#13)
	jr c,la5fd
	sub a
.la5fd
	ld (ix+#13),a
	dec (ix+#18)
	jr nz,la607
	res 5,c
.la607
	ld a,(ix+#12)
	bit 4,c
	jr z,la629
	ld b,a
	ld l,(ix+#0b)
	ld h,(ix+#0c)
	ld a,(hl)
	cp #54
	jr c,la621
	ld l,(ix+#09)
	ld h,(ix+#0a)
	ld a,(hl)
.la621
	inc hl
	ld (ix+#0b),l
	ld (ix+#0c),h
	add b
.la629
	ld hl,la6db
	ld d,#00
	add a
	ld e,a
	add hl,de
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld l,(ix+#1d)
	bit 6,l
	jr z,la683
	ld h,a
	ld b,(ix+#1a)
	sla b
	bit 7,l
	ld a,(ix+#1c)
	jr z,la64c
	bit 0,c
	jr nz,la66a
.la64c
	bit 5,l
	jr nz,la65c
	sub (ix+#1b)
	jr nc,la667
	set 5,(ix+#1d)
	sub a
	jr la667
.la65c
	add (ix+#1b)
	cp b
	jr c,la667
	res 5,(ix+#1d)
	ld a,b
.la667
	ld (ix+#1c),a
.la66a
	ex de,hl
	srl b
	sub b
	ld e,a
	ld a,d
	ld d,#00
	jr nc,la675
	dec d
.la675
	add #a0
	jr c,la681
.la679
	sla e
	rl d
	add #18
	jr nc,la679
.la681
	add hl,de
	ex de,hl
.la683
	ld a,c
	xor #01
	ld (ix+#00),a
	bit 2,c
	jr z,la6ae
	ld b,(ix+#0e)
	djnz la6ab
	ld c,(ix+#0d)
	bit 7,c
	jr z,la69a
	dec b
.la69a
	ld l,(ix+#07)
	ld h,(ix+#08)
	add hl,bc
	ld (ix+#07),l
	ld (ix+#08),h
	add hl,de
	ex de,hl
	jr la6ae
.la6ab
	ld (ix+#0e),b
.la6ae
	cpl
	and #03
.la6b2 equ $ + 1
	ld a,#38
	jr nz,la6bf
	ld a,(la3b5)
	xor #08
	ld (la402),a
	ld a,#07
.la6bf
	ld hl,la6d4
	xor (hl)
	and (ix+#1e)
	xor (hl)
	ld (hl),a
	ex de,hl
	ld a,(ix+#13)
	ret
.la6d4 equ $ + 7
.la6d3 equ $ + 6
.la6d1 equ $ + 4
.la6cf equ $ + 2
.la6cd
	db #00,#00,#00,#00,#00,#00,#00,#38
.la6da equ $ + 5
.la6d7 equ $ + 2
.la6d6 equ $ + 1
.la6d5
	db #0f,#0f,#0d,#00,#00,#00
.la6db
	dw #077c,#0708,#06b0,#0640
	dw #05ec,#0594,#0544,#04f8
	dw #04b0,#0470,#042c,#03f0
	dw #03be,#0384,#0358,#0320
	dw #02f6,#02ca,#02a2,#027c
	dw #0258,#0238,#0216,#01f8
	dw #01df,#01c2,#01ac,#0190
	dw #017b,#0165,#0151,#013e
	dw #012c,#011c,#010b,#00fc
	dw #00ef,#00e1,#00d6,#00c8
	dw #00bd,#00b2,#00a8,#009f
	dw #0096,#008e,#0085,#007e
	dw #0077,#0070,#006b,#0064
	dw #005e,#0059,#0054,#004f
	dw #004b,#0047,#0042,#003f
	dw #003b,#0038,#0035,#0032
	dw #002f,#002c,#002a,#0027
	dw #0025,#0023,#0021,#001f
	dw #001d,#001c,#001a,#0019
	dw #0017,#0016,#0015,#0013
	dw #0012,#0011,#0010,#000f
.la783
	db #0d,#10,#13,#17,#1b,#1e,#21,#24
	db #27,#29,#2b,#2d,#2f,#00,#03,#07
	db #87,#00,#04,#07,#87,#00,#03,#07
	db #0c,#87,#00,#04,#07,#0c,#87,#07
	db #0c,#0f,#87,#07,#0c,#10,#87,#03
	db #07,#0c,#87,#04,#07,#0c,#87,#00
	db #0c,#87,#00,#04,#87,#00,#03,#87
.la7c1 equ $ + 6
	db #00,#05,#87,#00,#07,#87,#00,#00
.la7c9 equ $ + 6
.la7c3
	dw la7c9,la851,la8a3,la935
	dw la935,la948,la935,la935
	dw la953,la953,la953,la953
	dw la948,la935,la935,la953
	dw la953,la953,la953,la948
	dw la935,la935,la953,la953
	dw la953,la953,la948,la935
	dw la935,la953,la953,la953
	dw la953,la948,la95c,la95c
	dw la95c,la95c,la95c,la95c
	dw la96e,la96e,la977,la977
	dw la980,la980,la95c,la95c
	dw la96e,la96e,la977,la977
	dw la980,la980,la95c,la95c
	dw la96e,la96e,la977,la977
	dw la980,la980,la95c,la95c
	dw la96e,la96e,la977,la977
.la851 equ $ + 6
	dw la980,la980,#0000,la9c2
	dw la9c2,la9c2,la989,la99e
	dw la9aa,la9b6,la989,la99e
	dw la9aa,la9b6,la9d6,la9e2
	dw la9e2,la9d6,la9ee,la9fa
	dw la9fa,laa06,lab12,lab1a
	dw lab1a,lab1a,lab1a,laa12
	dw laa30,laa45,laa5a,laa12
	dw laa30,laa45,laa5a,laa6f
	dw laa84,laa99,laaae,laa6f
	dw laa84,laa99,laaae,#0000
.la8a3
	dw laac3,laac3,laac3,laad6
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,lab12
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,lab12
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,lab12
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,lab12
	dw lab12,lab12,lab12,lab12
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,laad9
	dw laad9,laad9,laad9,lab12
	dw #0000
.la935
	db #bd,#8a,#88,#01,#01,#83,#df,#00
	db #71,#04,#e5,#18,#e1,#18,#e5,#13
.la948 equ $ + 3
	db #e1,#13,#87,#e5,#18,#e1,#18,#e5
.la953 equ $ + 6
	db #13,#e1,#17,#ef,#18,#87,#e5,#1a
.la95c equ $ + 7
	db #e1,#1a,#e5,#13,#e1,#13,#87,#8a
	db #88,#01,#01,#83,#df,#00,#71,#04
	db #e5,#0c,#e3,#0c,#e1,#0c,#07,#07
.la96e equ $ + 1
	db #87,#e5,#0e,#e3,#0e,#e1,#0e,#07
.la977 equ $ + 2
	db #07,#87,#e5,#05,#e3,#05,#e1,#05
.la980 equ $ + 3
	db #00,#00,#87,#e5,#07,#e3,#07,#e1
.la989 equ $ + 4
	db #07,#0e,#0e,#87,#8a,#88,#01,#01
	db #83,#df,#00,#71,#06,#e1,#80,#1f
	db #21,#24,#28,#29,#26,#24,#ef,#28
.la99e equ $ + 1
	db #87,#e1,#80,#1f,#21,#23,#24,#26
.la9aa equ $ + 5
	db #28,#24,#ef,#26,#87,#e1,#80,#1f
	db #21,#23,#24,#26,#28,#24,#ef,#23
.la9b6 equ $ + 1
	db #87,#e1,#80,#23,#21,#1f,#1d,#21
.la9c2 equ $ + 5
	db #1f,#1d,#ef,#1c,#87,#8a,#88,#01
	db #01,#83,#df,#00,#12,#04,#e1,#24
	db #24,#24,#e1,#23,#23,#23,#23,#23
.la9d6 equ $ + 1
	db #87,#e1,#80,#24,#23,#1f,#21,#24
.la9e2 equ $ + 5
	db #28,#29,#ef,#28,#87,#e1,#80,#24
	db #23,#21,#23,#24,#26,#28,#ef,#29
.la9ee equ $ + 1
	db #87,#e1,#80,#30,#2f,#2b,#2d,#30
.la9fa equ $ + 5
	db #32,#33,#ef,#34,#87,#e1,#80,#30
	db #2f,#2b,#2d,#2f,#2d,#2b,#ef,#29
.laa06 equ $ + 1
	db #87,#e1,#80,#30,#2f,#2e,#2d,#2c
.laa12 equ $ + 5
	db #2b,#29,#ef,#28,#87,#8a,#88,#01
	db #01,#83,#df,#00,#71,#06,#e1,#80
	db #28,#e0,#26,#28,#e1,#26,#e0,#24
	db #26,#e1,#24,#e0,#23,#24,#e1,#21
.laa30 equ $ + 3
	db #ef,#1f,#87,#e1,#80,#26,#e0,#24
	db #26,#e1,#24,#e0,#23,#24,#e1,#23
	db #e0,#21,#23,#e1,#24,#ef,#26,#87
.laa45
	db #e1,#80,#24,#e0,#23,#24,#e1,#23
	db #e0,#21,#23,#e1,#21,#e0,#1f,#21
.laa5a equ $ + 5
	db #e1,#1f,#ef,#21,#87,#e1,#80,#24
	db #e0,#23,#24,#e1,#23,#e0,#21,#23
	db #e1,#21,#e0,#1f,#21,#e1,#1f,#ef
.laa6f equ $ + 2
	db #23,#87,#e1,#80,#34,#e0,#32,#34
	db #e1,#32,#e0,#30,#32,#e1,#30,#e0
.laa84 equ $ + 7
	db #2f,#30,#e1,#2d,#ef,#2b,#87,#e1
	db #80,#32,#e0,#30,#32,#e1,#30,#e0
	db #2f,#30,#e1,#2f,#e0,#2d,#2f,#e1
.laa99 equ $ + 4
	db #30,#ef,#32,#87,#e1,#80,#30,#e0
	db #2f,#30,#e1,#2f,#e0,#2d,#2f,#e1
	db #2d,#e0,#2b,#2d,#e1,#2b,#ef,#2d
.laaae equ $ + 1
	db #87,#e1,#80,#30,#e0,#2f,#30,#e1
	db #2f,#e0,#2d,#2f,#e1,#2d,#e0,#2b
.laac3 equ $ + 6
	db #2d,#e1,#2b,#ef,#2f,#87,#8a,#88
	db #01,#01,#83,#df,#00,#12,#04,#e1
	db #28,#28,#28,#28,#28,#28,#28,#28
.laad9 equ $ + 4
.laad6 equ $ + 1
	db #87,#ef,#28,#87,#8b,#e1,#df,#00
	db #02,#05,#89,#1f,#8d,#00,#df,#00
	db #02,#07,#89,#01,#00,#00,#df,#00
	db #01,#09,#89,#07,#8d,#00,#df,#00
	db #02,#05,#89,#1f,#8d,#00,#df,#00
	db #02,#07,#89,#01,#00,#df,#00,#01
	db #09,#89,#07,#8d,#00,#df,#00,#02
.lab12 equ $ + 5
	db #07,#89,#01,#00,#87,#8a,#df,#00
.lab1a equ $ + 5
	db #f1,#01,#ef,#80,#87,#8a,#88,#01
	db #01,#83,#df,#00,#17,#01,#ef,#c3
	db #3c,#87
;
.game_name
	db "Miami Dice",0
.game_year
	db "1986",0
.game_publisher
	db "Bug Byte",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
